<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #outer{
            width: 400px;
            height: 400px;
            background-color: aqua;
        }
        #center{
            width: 200px;
            height: 200px;
            margin: 0 auto;
            background-color: blue;
        }
        #inner{
            width: 100px;
            height: 100px;
            margin: 0 auto;
            background-color: red;
        }
    </style>
    <script>
        window.onload=function(){
            var outer=document.getElementById('outer');
            var center=document.getElementById('center');
            var inner=document.getElementById('inner');
            // dom 2级事件绑定
            function handler(){
                console.log(this.id);
            }
            // 参数：事件类型 事件处理程序 布尔值 true-捕获 false-冒泡
            inner.addEventListener('click',handler,true)
            center.addEventListener('click',handler,true)
            outer.addEventListener('click',handler,true)
        }
    </script>
</head>
<body>
    <div id="outer">外部outer
        <div id="center">中间center
            <div id="inner">内部inner</div>
        </div>
    </div>
</body>
</html>